/**
 * 
 */
package com.csair.youth.dao.query.impl;

import java.util.Map;

import com.csair.youth.database.Employee;
import com.csair.youth.database.Notice;
import com.csair.youth.database.User;

import common.query.Query;
import common.query.QueryUtils;

/**
 * @author mickey
 *
 */
public class NoticeQueryDaoImpl extends BaseQueryDao {

	/* (non-Javadoc)
	 * @see com.csair.youth.dao.query.impl.BaseQueryDao#createQuery(java.util.Map)
	 */
	@Override
	protected Query createQuery(Map map) {
		// TODO Auto-generated method stub
		StringBuffer buf = new StringBuffer();
		buf.append(" from " + Notice.REF + " a,"+ User.REF+" b,"+ User.REF+" c ");
		buf.append(" where 1=1 ");
		buf.append(" and a." + Notice.PROP_PUBLISH_USER_ID + " = b."+User.PROP_ID);
		buf.append(" and a." + Notice.PROP_LAST_MODIFY_USER_ID + " = c."+User.PROP_ID);
		buf.append("  /~ and a." + Notice.PROP_TITLE + " like {title?string_fl} ~/");
		buf.append("  /~ and b." + User.PROP_NAME + " like {publishUserName?string_fl} ~/");
		Query query = QueryUtils.filterQuery(buf.toString(), map);
		return query;
	}

	/* (non-Javadoc)
	 * @see com.csair.youth.dao.query.impl.BaseQueryDao#createSelect(java.lang.String)
	 */
	@Override
	protected String createSelect(String temp) {
		// TODO Auto-generated method stub
		StringBuffer sb = new StringBuffer();
		sb.append("select a."+Notice.PROP_ID+",");
		sb.append(" a."+Notice.PROP_TITLE+",");
//		sb.append(" a."+Notice.PROP_CONTENT+",");
		sb.append(" a."+Notice.PROP_PUBLISH_TIME+",");
		sb.append(" a."+Notice.PROP_LAST_MODIFY_TIME+",");
		sb.append(" b."+User.PROP_NAME+",");
		sb.append(" c."+User.PROP_NAME+" ");
		return sb.toString()+temp;
	}

}
